#include "Expression.hpp"
#include "CodeContainer.hpp"

#include <iostream>
using namespace std;

Expression::Expression() {
	this->type = NULL;
	this->value = NULL;
	this->calculated = false;
	this->adressable = false;
	this->identTempResult = -1;
	this->code = NULL;
}

Expression::Expression(Type * type, int identValue) {
	this->type = type;
	this->value = NULL;
	this->calculated = false;
	this->adressable = false;
	this->identTempResult = identValue;
	this->code = NULL;
}

Expression::Expression(Type* type, Value* value, bool calculated, bool adressable, int ident, CodeContainer* code) {
	this->type = type;
	this->value = value;
	this->calculated = calculated;
	this->adressable = adressable;
	this->identTempResult = ident;
	this->code = code;
}

Expression * Expression::clone() {
	Expression * e = new Expression();
	e->type = this->getType();
	e->value = this->getValue();
	e->calculated = this->isCalculated();
	e->adressable = this->isAdressable();
	e->identTempResult = this->getIdentTempResult();
	e->code = this->getCode();
	return e;
}

Expression::~Expression() {
	//delete this->type;
	//delete this->value;
	//delete this->code;
}

void Expression::setType(Type* type) {
	this->type = type;
}

void Expression::setValue(Value* value) {
	this->value = value;

}

void Expression::setCalculated(bool calculated) {
	this->calculated = calculated;
}

void Expression::setAdressable(bool adressable) {
	this->adressable = adressable;
}

void Expression::setIdentTempResult(int ident) {
	this->identTempResult = ident;
}

void Expression::setCode(CodeContainer* code) {
	this->code = code;
}

bool Expression::isAdressable() {
	return adressable;
}

bool Expression::isCalculated() {
	return calculated;
}

CodeContainer* Expression::getCode() {
	return code;
}

int Expression::getIdentTempResult() {
	return identTempResult;
}

Type* Expression::getType() {
	return type;
}

Value* Expression::getValue() {
	return value;
}

void Expression::show() {
	cout << endl << "****Expression" << endl;
	if (type == NULL) { //si je met
	} else {
		cout << "	type : "; type->show(); cout << endl;
	}
	if (value == NULL) {
	} else {
		cout << "	value : "; value->show(); cout << endl;
	}
	cout << "	calculated : " << calculated << endl;
	cout << "	adressable : " << adressable << endl;
	if (identTempResult != -1)
		cout << "	identTempResult : " << identTempResult << endl;
	if (code == NULL) {
	} else {
		cout << "	code : TODO show" /*<< code->show()*/ << endl;
	}
}
